package com.seeyon.apps.seepkk.form.workflowevent;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.seeyon.apps.kk.form.workflowevent.KkBaseExtendPlug;
import com.seeyon.apps.seepkk.manager.SeepManager;
import com.seeyon.cap4.form.bean.FormBean;
import com.seeyon.cap4.form.bean.FormDataMasterBean;
import com.seeyon.ctp.common.constants.ApplicationCategoryEnum;
import com.seeyon.ctp.workflow.event.WorkflowEventData;
import com.seeyon.ctp.workflow.event.WorkflowEventResult;

public class TongKkExtendPlug extends KkBaseExtendPlug {

	private static final Log log = LogFactory.getLog(TongKkExtendPlug.class);
	private SeepManager seepManager;

	@Override
	public String getId() {
		// TODO Auto-generated method stub
		return "tongKkExtendPlug";
	}

	public SeepManager getSeepManager() {
		return seepManager;
	}

	public void setSeepManager(SeepManager seepManager) {
		this.seepManager = seepManager;
	}

	@Override
	public String getLabel() {
		// TODO Auto-generated method stub
		return "自定义控件通用必填验证";
	}
	
	public ApplicationCategoryEnum getAppName() {
		return ApplicationCategoryEnum.form;
	}

	// 发起前事件
	public WorkflowEventResult onBeforeStart(WorkflowEventData data) {
		WorkflowEventResult result = new WorkflowEventResult();
		FormBean formBean = (FormBean) data.getBusinessData().get("formBean");
		FormDataMasterBean formDataMasterBean = (FormDataMasterBean) data.getBusinessData().get("formDataBean");

		// 非空验证
		String resultMsg = this.seepManager.customControlCheck(formBean, formDataMasterBean.getAllDataMap());
		result.setAlertMessage(resultMsg);
		return result;
	}
}
